<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="客户">
              <a-input placeholder="请输入客户" v-model="queryParam.custName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
        selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical"/>
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import TpmAuditModal from './modules/TpmAuditModal'
  import { PageListMixin } from '@/mixins/PageListMixin'

  export default {
    name: 'TpmSalesList',
    mixins: [PageListMixin],
    components: {
      TpmAuditModal
    },
    props: ['tempUuid'],
    data() {
      return {
        description: '关联活动销售数据',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },

          {
            title: '活动编号',
            align: 'center',
            dataIndex: 'actCode'
          },
          {
            title: '活动名称',
            align: 'center',
            dataIndex: 'actName'
          },
          {
            title: '客户编号',
            align: 'center',
            dataIndex: 'custCode'
          },
          {
            title: '客户名称',
            align: 'center',
            dataIndex: 'custName'
          },
          {
            title: '门店编号',
            align: 'center',
            dataIndex: 'terminalCode'
          },
          {
            title: '门店名称',
            align: 'center',
            dataIndex: 'terminalName'
          },
          {
            title: '活动时间',
            align: 'center',
            dataIndex: 'actDate'
          },

          {
            title: '活动销量',
            align: 'center',
            dataIndex: 'salesNum'
          },
          {
            title: '活动销售额',
            align: 'center',
            dataIndex: 'salesMoney'
          }
        ],
        url: {
          list: window._CONFIG['domianTpmURL'] + '/audit/tpmActSales/findPageList'
        }
      }
    },
    created() {
      this.queryParam.tempUuid = this.tempUuid
    },
    computed: {},
    methods: {}
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>